package com.jake.springboot.mybatis.service.impl;

import com.jake.springboot.mybatis.domain.Person;
import com.jake.springboot.mybatis.domain.Person2;
import com.jake.springboot.mybatis.domain.PersonJson;
import com.jake.springboot.mybatis.mapper.PersonMapper;
import com.jake.springboot.mybatis.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {

    @Autowired
    private PersonMapper personMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insert(Person person) {
        return personMapper.insert(person);
    }

    @Override
    public List<Person> getPersons() {
        return personMapper.getPersons();
    }

    @Override
    public List<Person2> getPerson2s() {
        return personMapper.getPerson2s();
    }

    @Override
    @Transactional
    public int update(int personId, PersonJson personJson) {
        return personMapper.update(personId, personJson);
    }

    @Override
    public PersonJson getPersonJsonById(int personId) {
        return personMapper.getPersonJsonById(personId);
    }

}
